<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta charset=UTF-8>
<title></title>
<script src="${webroot }js/jquery.min.js"></script>
<script src="${webroot }js/bootstrap.min.js"></script>
<link rel="stylesheet" href="${webroot }css/bootstrap.min.css">
<link rel="stylesheet" href="${webroot }css/common.css">
<link rel="stylesheet" href="${webroot }css/client.css">
<script src="${webroot }js/func.action.js"></script>
<script src="${webroot }js/web.config.js"></script>
</head>
<body>
	<form class="bs-example bs-example-form"
		action="${webroot }web/stu/search" method="post">
		<div class="input-group search">
			<input type="text" name="stuNo" class="form-control" /> <span
				class="input-group-btn">
				<button class="btn btn-default" type="submit">
					<!--  <span class="glyphicon glyphicon-search"></span>-->
					Go!
				</button>
			</span>
		</div>
		<!-- /input-group -->
	</form>
	<table class="table">
		<thead>
			<tr>
				<td>编号</td>
				<td>学号</td>
				<td>姓名</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${list }" var="stu">
				<tr>
					<td>${stu.stuId }</td>
					<td>${stu.stuNo }</td>
					<td>${stu.stuPass }</td>
					<td><c:if test="${stu.stuStatus == 1 }">
							<a href="#" onclick="updateStuStatus(${stu.stuId},2)">禁用</a>
						</c:if> <c:if test="${stu.stuStatus == 2 }">
							<a href="#" onclick="updateStuStatus(${stu.stuId},1)">启用</a>
						</c:if> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#"
						onclick="reset(${stu.stuId})">重置密码</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a
						href="#" onclick="stuDetail(${stu.stuNo})">详细信息</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="info_footer">
		<div class="footer_con">
			<div class="btn-group dropup info_choose ">
				<span class="dropdown-toggle" id="status_menu" role="0"
					data-toggle="dropdown"> <c:if test="${status <= 0 }">
      	全部状态
      </c:if> <c:if test="${status == 1 }">
      	激活状态
      </c:if> <c:if test="${status == 2 }">
      	禁用状态
      </c:if>
				</span><span class="caret"></span>
				<ul class="dropdown-menu" role="menu" id="status_item">
					<li><a role="0"
						href="${webroot }web/stu/query?page=1&status=0">全部类型</a></li>
					<li><a role="1"
						href="${webroot }web/stu/query?page=1&status=1">激活状态</a></li>
					<li><a role="2"
						href="${webroot }web/stu/query?page=1&status=2">禁用状态</a></li>
				</ul>
			</div>
			<div class="info_page">
				<ul class="pagination">
					<li><a id="pre_page" role="1" href="#">&laquo;</a></li>
					<li><a id="next_page" role="2" href="#">&raquo;</a></li>
				</ul>
				<div class="btn-group dropup">
					<button type="button" class="btn btn-default dropdown-toggle"
						id="page_menu" data-toggle="dropdown">
						第 ${page } 页<span class="caret"></span>
					</button>
					<ul class="dropdown-menu" role="menu" id="info_page">

					</ul>
				</div>
			</div>
		</div>
	</div>
	<div class="hidden_area">
		<input type="hidden" value="${page }" id="page"> <input
			type="hidden" value="${pages }" id="pages"> <input
			type="hidden" value="${status }" id="status">
	</div>

	<div class="modal fade" id="info" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">详细信息</h4>
				</div>
				<div class="modal-body">
					<table class="table">
						<tbody>
							<tr>
								<td>预约总次数：</td>
								<td id="rec"></td>
								<td>确认入座次数：</td>
								<td id="sure"></td>
							</tr>
							<tr>
								<td>取消预约次数：</td>
								<td id="cancel"></td>
								<td></td>
								<td></td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>

	<script type="text/javascript">
		$(document).ready(function(){
			$("#pre_page").click(function(){
	    		var page = $("#page").val();
	    		if(page <= 1){
	    			alert("已经是第一页了");
	    		}else{
	    			var now = page - 1;
	    			var status = $("#status").val();
	    			window.location.href= webRoot + "web/stu/query?page="+now+"&status="+status;
	    		}
	    	});
	    	$("#next_page").click(function(){
	    		var page = $("#page").val();
	    		var pages = $("#pages").val();
	    		if(pages <= page){
	    			alert("已经是最后一页了");
	    		}else{
	    			var now = parseInt(page) + 1;
	    			var status = $("#status").val();
	    			window.location.href= webRoot + "web/stu/query?page="+now+"&status="+status;
	    		}
	    	});
	    	
	    	var page = $("#page").val();
	    	var pages = $("#pages").val();
	    	var status = $("#status").val();
	    	var doc_page = $("#info_page");
	    	doc_page.empty();
	    	for (var i = 0; i < pages; i++) {
	    		var cur = i + 1;
	    		if (i != (page - 1)) {
	    			doc_page.append("<li><a href='"+webRoot+"web/stu/query?page="+cur+"&status="+status+"'>第"+cur+"页</a></li>");
	    		}
	    	}
		});
	</script>
</body>
</html>